package com.libgdxbar.pvzlikegame.entities;

import com.badlogic.gdx.math.Vector2;

// 可移动的实体
public class MoveableEntity extends LocationEntity {
	final Vector2 velocity;

	public MoveableEntity() {
		this(0, 0);
	}

	public MoveableEntity(Vector2 position) {
		this(position.x, position.y);
	}

	public MoveableEntity(float x, float y) {
		this(x, y, 0, 0);
	}

	public MoveableEntity(Vector2 position, Vector2 velocity) {
		this(position.x, position.y, velocity);
	}

	public MoveableEntity(float x, float y, Vector2 velocity) {
		this(x, y, velocity.x, velocity.y);
	}

	public MoveableEntity(float x, float y, float velocityX, float velocityY) {
		super(x, y);
		velocity = new Vector2(velocityX, velocityY);
	}

	@Override
	public void run(float delta) {
		position.x += getVelocityX() * delta;
		position.y += getVelocityY() * delta;
	}

	public Vector2 getVelocity() {
		return velocity;
	}

	public void setVelocity(Vector2 velocity) {
		velocity.set(velocity);
	}

	public void setVelocity(float velocityX, float velocityY) {
		velocity.set(velocityX, velocityY);
	}

	public float getVelocityX() {
		return velocity.x;
	}

	public void setVelocityX(float velocityX) {
		velocity.x = velocityX;
	}

	public float getVelocityY() {
		return velocity.y;
	}

	public void setVelocityY(float velocityY) {
		velocity.y = velocityY;
	}
}
